axios.interceptors.request.use(req=>{
    req.headers.accesstoken=localStorage.getItem("accessToken");
    return req;
})
axios.interceptors.response.use(resp=>{
    if (resp.headers.accesstoken!=null){
        localStorage.setItem("accessToken",resp.headers.accesstoken)
    }
    return resp;
})
new Vue({
    el:"#app",
    data:{
        showDetailWindow:false,
        showRejectRegister:false,
        storeRegisterList:{},
        storeRegisterDetail:{},
        attachment:[],
        registerStates:[{
            value: 0,
            label:'待审核',
        },{
            value: 1,
            label:'审核通过',
        },{
            value: 2,
            label:'审核不通过',
        },{
            value: 3,
            label:'取消审核',
        }],
        stateId:"",
        startTime:"",
        endTime:"",
        storeRegisterRejectReason:""
    },
    methods:{
        loadAllStoreRegister(pageIndex,pageSize,startTime,endTime,stateId){
            axios.get("/storeRegister/list",{
                params:{
                    pageIndex:pageIndex,
                    pageSize:pageSize,
                    startTime:startTime,
                    endTime:endTime,
                    stateId:stateId
                }
            }).then(resp=>{
                this.storeRegisterList=resp.data.data
            })
        },loadRegisterDetail(storeRegisterId){
            axios.get("/storeRegister/detail",{
                params: {
                    storeRegisterId:storeRegisterId
                }
            }).then(resp=>{
                console.log(resp)
                this.storeRegisterDetail=resp.data.data
            })
        },viewDetail(obj){
            this.showDetailWindow=true;
            this.loadRegisterDetail(obj.storeRegisterId)
        },findByState(){
            this.loadAllStoreRegister(this.storeRegisterList.pageIndex,this.storeRegisterList.pageSize,null,null,this.stateId)
        },getByTime(){
            this.loadAllStoreRegister(this.storeRegisterList.pageIndex,this.storeRegisterList.pageSize,this.startTime,this.endTime,this.stateId)
        }
        ,handleSizeChange(pageSize){
            this.loadAllStoreRegister(1,pageSize,null,null,this.stateId)
        },handleCurrentChange(pageIndex){
            this.loadAllStoreRegister(pageIndex,this.storeRegisterList.pageSize,null,null,this.stateId)
        },handleClose(){
            this.showDetailWindow=false
        },handleClose2(){
            this.storeRegisterRejectReason=""
            this.showRejectRegister=false
        },
        remakeQuery(){
            this.stateId=""
            this.startTime=""
            this.endTime=""
            this.loadAllStoreRegister(1,3,null,null,null)
        },passRegister(){
            axios.post("/storeRegister/pass",{
                storeRegisterId:this.storeRegisterDetail.storeRegisterId
            }).then(resp=>{
                alert(resp.data.message)
                this.showRejectRegister=false
                this.showDetailWindow=false
                this.loadAllStoreRegister(1,3,null,null,null)
            })
        },rejectRegister(){
            if (this.storeRegisterRejectReason==null||this.storeRegisterRejectReason==""){
                alert("必须填写拒绝原因")
            }else {
                axios.post("/storeRegister/reject", {
                    storeRegisterId: this.storeRegisterDetail.storeRegisterId,
                    storeRegisterRejectReason: this.storeRegisterRejectReason
                }).then(resp => {
                    alert(resp.data.message)
                    this.showDetailWindow = false
                    this.showRejectRegister = false
                    this.storeRegisterRejectReason = ""
                    this.loadAllStoreRegister(1,3,null,null,null)
                })
            }
        }
    },created(){
        this.loadAllStoreRegister(1,3,null,null,null)
    }


})